Directed acyclic graphs are the brain child of computer scientist Judea Pearl, who developed them to reason systemically about causal inference. Judea Pearl’s The Book of Why provides an accessible introduction to directed acyclic graphs and makes for a nice holiday reading.
DAGs are build from two types of components:
All graphs are made of nodes and edges. What is special about directed acyclic graphs is that
C_dag = dagitty(
"dag{
S->B;
S->D;
B->D
}")
coord.list =
list(
x=c(B=0,D=2,S=1),
y=c(B=0,D=0,S=-1))
coordinates(C_dag) = coord.list
drawmydag(C_dag, cex = 1, lwd = 1)
C_dag_A = C_dag
adjustedNodes(C_dag_A) = "S"
drawmydag(C_dag_A, cex = 1, lwd = 1)
| Confounding bias | Adjustment |
|---|---|
M_dag = dagitty(
"dag{
M->W;
T->M;
T->W
}")
coord.list =
list(
x=c(T=0,W=2,M=1),
y=c(T=0,W=0,M=-1))
coordinates(M_dag) = coord.list
drawmydag(M_dag, cex = 1, lwd = 1)
M_dag_A = M_dag
adjustedNodes(M_dag_A) = "M"
drawmydag(M_dag_A, cex = 1, lwd = 1)
| Mediation by M | Bias from adjustment of mediator |
|---|---|
Cl_dag = dagitty(
"dag{
I->B;
E->B;
E->I
}")
coord.list =
list(
x=c(E=0,I=2,B=1),
y=c(E=0,I=0,B=1))
coordinates(Cl_dag) = coord.list
drawmydag(Cl_dag, cex = 1, lwd = 1)
Cl_A_dag = Cl_dag
adjustedNodes(Cl_A_dag) = "B"
drawmydag(Cl_A_dag, cex = 1, lwd = 1)
| Collider | Selection bias from conditioning on a collider |
|---|---|
If one has multiple measurements of the same variable over time, each measurement would be a new node↩︎